﻿#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_

/**
* @file mainwindow.h
* @author 杨少华
* @create_time 20250516
* @brief ui界面
* @version V1 ysh-initial version
*/

#include <QMainWindow>
#include <QFileDialog>
#include <QColorDialog>
#include "shapeparameter.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
	MainWindow(QWidget* parent = nullptr);
	~MainWindow();
	void moveCanvasToCenter();

public slots:
	void onCleanCanvasClicked();
	void onExportPNGBtnClicked();
	void onSelectButtonClicked();
	void onLineButtonClicked();
	void onCircleButtonClicked();
	void onRectButtonClicked();
	void onPentagonButtonClicked();
	void onHexagonButtonClicked();
	void onPentagramButtonClicked();
	void onSetCanvasWidth(int width);
	void onSetCanvasHeight(int height);
	void onZoomCanvas(qreal scale);
	void setCanvasColor();
	void onSetShapeBorderWidth(int width);
	void onSetBorderWidthSpinBoxValue(int width);
	void onSetShapeBorderStyle(Qt::PenStyle style);
	void onSetShapeBorderColor();
	void onSetShapeBorderColorButtonColor(QRgb color);
	void onSetShapeColor();
	void onSetShapeColorButtonColor(QRgb color);
	void onIsSelectShape(bool isSelected);
private:
	QRgb selectColor();
	virtual bool eventFilter(QObject* watched, QEvent* event) override;

signals:
	void onDrawingFlagChanged(Canvas::DrawFlag drawFlag);

private:
	Ui::MainWindow* ui;
	double m_currentCanvasScale = 1.0;
	bool m_isSelectShape = false;
	int m_preShapeBorderWidth = 2;
	//bool m_isRestoreWidth;
};
#endif // !_MAINWINDOW_H_
